package zhihuilan.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import zhihuilan.entity.MyUser;
import zhihuilan.mapper.MyUserMapper;
import zhihuilan.service.MyUserService;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 部门管理 服务实现
 *
 * @author ruoyi
 */
@Service
public class MyUserServiceImpl implements MyUserService {
    @Autowired
    private MyUserMapper myUserMapper;

    @Override
    public List<MyUser> selectUserList(Integer pageSize, Integer pageNum, String userName) {
        QueryWrapper<MyUser> queryWrapper = new QueryWrapper<>();
        if (!ObjectUtils.isEmpty(userName)) {
            queryWrapper.eq("username", userName);
        }
        List<MyUser> result = myUserMapper.selectList(queryWrapper);
        return result;
    }

    @Override
    public MyUser selectUserById(Integer id) {
        return myUserMapper.selectById(id);
    }

    @Override
    public MyUser selectUserByChannel(String channel) {
        QueryWrapper<MyUser> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("channel", channel);
        MyUser result = myUserMapper.selectOne(queryWrapper);
        return result;
    }
}
